<template>
  <div class="reply">
    <div class="fixed">
      <van-nav-bar
        :title="
          comment.reply_count ? comment.reply_count + '条回复' : '暂无回复'
        "
        @click-left="$emit('close')"
      >
        <van-icon slot="left" name="cross" />
      </van-nav-bar>

      <commentItem :comment="comment" />
      <van-cell value="全部回复" />
    </div>

    <comment
      type="c"
      :source="comment.com_id + ''"
      :list="list"
      class="comment"
    />

    <div class="post-warp">
      <van-button round @click="isShowPostComment = true">评论</van-button>
    </div>

    <!-- 评论回复弹出层 -->
    <van-popup v-model="isShowPostComment" position="bottom">
      <commentPost :target="comment.com_id" @unshiftList="unshift" />
    </van-popup>
  </div>
</template>

<script>
import commentItem from '../commentItem'
import comment from '../comment'
import commentPost from '../commentPost'
export default {
  props: ['comment'],
  data () {
    return {
      list: [],
      isShowPostComment: false
    }
  },
  components: {
    commentItem,
    comment,
    commentPost
  },
  created () {},

  methods: {
    unshift (data) {
      this.list.unshift(data)
      this.isShowPostComment = false
      this.comment.reply_count++
    }
  }
}
</script>

<style scoped lang="less">
.post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  .van-button {
    width: 640px;
    height: 80px;
  }
}
.fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
}
.comment {
  position: fixed;
  top: 416px;
  bottom: 102px;
  overflow-y: scroll;
  left: 0;
  right: 0;
}
</style>
